﻿@model ThreadEditModel
@{
    TempData["subMenu-check"] = new string[] { "Sections", "ManageThreads" };
    var selectListItems = ViewData.Get<List<SelectListItem>>("selectListItems", null);
    ViewData["Title"] = new string[] { "编辑" + Model.Subject };
    var attachmentList = ViewData.Get<IEnumerable<Attachment>>("attachmentList", null);
    var associateId = Model.ThreadId > 0 ? Model.ThreadId : IdGenerator.Next();
}
<!--@Scripts.Render("~/Bundle/Scripts/ueditor")-->
<script>
    require(['jquery', 'ZeroClipboard', 'ueditor'], function ($, ZeroClipboard) {
       window['ZeroClipboard'] = ZeroClipboard;
    })
</script>


<div class="row tn-page-heading tn-mb-20">
    <div class="col-xs-12">
        <ol class="breadcrumb">
            <li class="tn-active">编辑贴子</li>
        </ol>
    </div>
</div>
<div class="panel panel-default tn-survey-form">
    <div class="panel-body">
        @using (Html.BeginForm("EditThread", "ControlPanel", FormMethod.Post, new { @class = "form-horizontal tn-form-validation", @id = "EditThread" }))
            {
            @Html.HiddenFor(n => n.ThreadId)
            @Html.HiddenFor(n => n.SectionId)
            <div class="form-group">
                <div class="col-xs-12">
                    @Html.TextBoxFor(n => n.Subject, new { @class = "form-control", @placeholder = "标题" })
                    @Html.ValidationMessageFor(n => n.Subject)
                </div>
            </div>
            <div class="form-group">
                <div class="col-xs-12">
                    @Html.HtmlEditor("Body",TenantTypeIds.Instance().Thread(), associateId, Model.Body,new Dictionary<string, object> { { "style", "height:400px;" }, { "maximumWords", 20000 } , { "initialFrameWidth", "100%" }})
                    @Html.ValidationMessageFor(n => n.Body)
                    <div id="Attachments" class="tn-mt-10">
                        @if (attachmentList != null && attachmentList.Any())
                        {
                            foreach (var item in attachmentList)
                            {
                                if (!item.IsShowInAttachmentList)
                                {
                                    continue;
                                }
                                <div class="tn-file-attachment tn-mb-10 text-left">
                                    <i class="fa fa-file-o"></i>
                                    @item.FriendlyFileName
                                    <a href="javascript:;" data-id="@item.AttachmentId" id="delete-@item.AttachmentId" class="pull-right remove-file">删除</a>
                                </div>
                            }
                        }
                    </div>
                </div>
            </div>
            if (selectListItems != null)
            {
                <div class="form-group">
                    <label class="col-xs-2 control-label tn-width-90">贴子分类</label>
                    <div class="col-xs-4">
                        <div class="has-feedback">
                            @Html.DropDownListFor(n=>n.CategoryId, selectListItems, new { @class = "form-control" })
                        </div>
                    </div>
                </div>
            }
            <div class="form-group">
                <div class="col-xs-4 col-xs-offset-2">
                    <button id="answer" type="submit" class="btn btn-primary btn-submit">确定</button>
                    <a type="button" class="btn btn-default" href="@SiteUrls.Instance().ManageThreads()">返回</a>
                </div>
            </div>
        }
    </div>
</div>

